import request from '@/config/axios'

// 店员申请 VO
export interface ClerkApplyVO {
  id: number // 编号
  workerClerkId: number // 店员编号
  userId: number // 用户编号
  nickname: string // 昵称
  avatar: string // 头像
  sex: string // 性别
  age: number // 年龄
  weixin: string // 微信
  mobile: string // 手机号
  city: string // 城市
  experience: string // 相关经验
  sound: string // 录音
  soundType: string // 音频格式
  soundTime: number // 音频时长
  albums: string // 相册
  intro: string // 介绍
  onlineTime: string // 接单时间
  workerClerkLevelId: string // 店员等级编号
  status: number // 审核状态
}

export interface ClerkApplySaveReqVO {
  id: number // 编号
  categoryList: CategoryRespVO 
}

export interface CategoryRespVO {
  id: number // 编号
  goodsList: WorkerGoodsVO 
  categoryList: CategoryRespVO
}

export interface WorkerGoodsVO {
  id: number // 编号
  deleted: boolean 
}

// 店员申请 API
export const ClerkApplyApi = {
  // 查询店员申请分页
  getClerkApplyPage: async (params: any) => {
    return await request.get({ url: `/worker/clerk-apply/page`, params })
  },

  // 查询店员申请详情
  getClerkApply: async (id: number) => {
    return await request.get({ url: `/worker/clerk-apply/get?id=` + id })
  },
  
  // 查询店员申请技能列表
  getWorkerGoodsList: async (id: number) => {
    return await request.get({ url: `/worker/clerk-apply/getWorkerGoodsList?id=` + id })
  },

  // 新增店员申请
  createClerkApply: async (data: ClerkApplyVO) => {
    return await request.post({ url: `/worker/clerk-apply/create`, data })
  },
  
  // 店员申请状态修改
  updateClerkApplyStatus: async (id: number, status: number) => {
    const data = {
      id,
      status
    }
    return await request.put({ url: '/worker/clerk-apply/update-status', data: data })
  },

  // 修改店员申请
  updateClerkApply: async (data: ClerkApplyVO) => {
    return await request.put({ url: `/worker/clerk-apply/update`, data })
  },
  
  // 保存店员申请技能
  saveWorkerGoodsList: async (data: ClerkApplySaveReqVO) => {
    return await request.put({ url: `/worker/clerk-apply/saveWorkerGoodsList`, data })
  },

  // 删除店员申请
  deleteClerkApply: async (id: number) => {
    return await request.delete({ url: `/worker/clerk-apply/delete?id=` + id })
  },

  // 导出店员申请 Excel
  exportClerkApply: async (params) => {
    return await request.download({ url: `/worker/clerk-apply/export-excel`, params })
  },
}